package opt.power.springdemo.login.service;

import lombok.extern.slf4j.Slf4j;
import opt.power.springdemo.user.mapper.UserMapper;
import opt.power.springdemo.user.mapper.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xuliduo
 * @date 2017/11/17
 * @description class LoginService
 */
@Slf4j
@Service
public class LoginService {

    UserMapper userMapper;

    @Autowired
    LoginService(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    /**
     * 登录验证
     *
     * @param user user
     * @return 是否正确
     */
    public boolean checkLogin(User user) {
        log.debug("username={}",user.getName());
        return userMapper.findByNameAndPassword(user).size() > 0;
    }
}
